﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace H.Y.Clipboard
{
    internal class FormChecker
    {
        private static int i_a = (int)'a';
        private static int i_z = (int)'z';
        private static int i_A = (int)'A';
        private static int i_Z = (int)'Z';
        private static int i_0 = (int)'0';
        private static int i_9 = (int)'9';

        public static bool isOnlyLetterAndNumber(String str)
        {
            char[] chars = str.ToCharArray();
            for (int i = 0; i < str.Count(); i++)
            {
                char ch = chars[i];
                if ((!isLetter(ch)) && (!isNumber(ch))) return false;
            }
            return true;
        }

        private static bool isLetter(char c)
        {
            int i = (int)c;
            return (i <= i_Z && i >= i_A) || (i <= i_z && i >= i_a);
        }

        private static bool isNumber(char c)
        {
            int i = (int)c;
            return (i <= i_9 && i >= i_0);
        }
    }
}
